﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AliyunOpenSearch4Net.Base;
using Newtonsoft.Json;

namespace AliyunOpenSearch4Net.Search
{
    class ScanRequest : RequestBase<Response<ScanResult>>
    {
        public ScanRequest()
            : base(string.Empty)
        {

        }

        public string IndexName { get; set; }

        public string Query { get; set; }

        public string Scroll { get; set; }

        public string SearchType { get; set; }

        public string ScrollId { get; set; }

        protected override void RegisterQueryItems(IList<KeyValuePair<string, string>> list)
        {
            list.Add("scroll", Scroll);

            list.Add("index_name", IndexName);

            if (!string.IsNullOrEmpty(Query))
                list.Add("query", Query);

            if (!string.IsNullOrEmpty(SearchType))
                list.Add("search_type", SearchType);

            if (!string.IsNullOrEmpty(ScrollId))
                list.Add("scroll_id", ScrollId);
        }
    }

    /// <summary>
    /// Scan result
    /// </summary>
    public class ScanResult : SearchResult
    {
        /// <summary>
        /// Gets or sets the scroll id.
        /// </summary>
        /// <value>
        /// The scroll id.
        /// </value>
        [JsonProperty("scroll_id")]
        public string ScrollId { get; set; }
    }
}
